/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entidades;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import utilitarios.DataHora;


/**
 *
 * @author renan
 */
@Entity
@Table(name = "RESERVA")
public class Reserva implements Serializable{

    @Id
    @Column(name ="REID")
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private String id;

    @JoinColumn(name="RECLIENTE",referencedColumnName="CLID")
    @ManyToOne(optional = false)
    private Cliente cliente;
    @Column(name = "REDATAHORA")
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date dataHora;
    private String dataHoraString;
    private String situacao;

    public Reserva(){
        cliente = new Cliente();
    }

    public Cliente getCliente() {
        return cliente;
    }

    public void setCliente(Cliente cliente) {
        this.cliente = cliente;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Date getDataHora() {
        return dataHora;
    }

    public void setDataHora(Date dataHora) {
        this.dataHora = dataHora;
        this.dataHoraString=DataHora.dataParaString(dataHora);
    }
    
    public void setDataHoraString(String dataHoraString) {
        this.dataHoraString = dataHoraString;
    }
    
    public String getDataHoraString() {
        return dataHoraString;
    }
    
    public void setSituacao(String situacao) {
        this.situacao = situacao;
    }
    
    public String getSituacao() {
        return situacao;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Reserva other = (Reserva) obj;
        if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 3455;
        hash = 37 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }


}
